package com.manner.groupon.controller.staff;

import com.manner.groupon.common.BaseResponse;
import com.manner.groupon.common.ResultUtils;
import com.manner.groupon.model.entity.GrouponCoupons;
import com.manner.groupon.model.enums.GrouponCouponsStatus;
import com.manner.groupon.service.groupon.GrouponCouponsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Manner
 * @Description: 平台内部员工 对 该店铺的团购优惠券 操作请求控制器
 * @DateTime: 2024/11/10 15:39
 */
@RestController("staffGrouponCouponsController")
@RequestMapping("/staff/groupon")
@RequiredArgsConstructor
public class GrouponCouponsController {

    private final GrouponCouponsService grouponCouponsService;

    /**
     * @param grouponCoupons
     * @return BaseResponse
     * @description: 平台内部员工编辑更新团购券信息
     * @author Manner
     * @date 2024/11/10 16:43
     */
    public BaseResponse edit(GrouponCoupons grouponCoupons) {
        grouponCouponsService.staffEdit(grouponCoupons);
        return ResultUtils.success("编辑更新团购券信息成功,等待管理员审核!");
    }

    /**
     * @param grouponCoupons
     * @return GrouponCoupons
     * @description: 平台内部员工上架团购优惠券以及团购套餐
     * @author Manner
     * @date 2024/11/10 15:44
     */
    @PutMapping("/add")
    public BaseResponse listingCoupons(GrouponCoupons grouponCoupons) {
        grouponCoupons.setStatus(GrouponCouponsStatus.UNAUDITED.getCode());
        grouponCouponsService.save(grouponCoupons);
        return ResultUtils.success("成功添加团购优惠券!");
    }
}
